package com.candy.candyuser;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.retry.annotation.EnableRetry;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

@Slf4j
@EnableRetry
@SpringBootApplication
public class CandyUserApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(CandyUserApplication.class, args);

        String userName = applicationContext.getEnvironment().getProperty("user.name");
        String userAge = applicationContext.getEnvironment().getProperty("user.age");
        System.out.println("common name :" + userName + "; age: " + userAge);

        BlockingQueue<String> queue = new ArrayBlockingQueue<>(16);
        try {
            log.info(System.currentTimeMillis() + "");
            queue.poll(5, TimeUnit.SECONDS);
            log.info(System.currentTimeMillis() + "");
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

}
